home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MACD 5
/
MACD 5.bin
/
workbench
/
libs
/
newlooklib.lha
/
newlook
/
createlistview.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-24
|
3KB
|
104 lines
/*
* CREATELISTVIEW.C
*/
#include "newlook.h"
extern LONG IntuiTextLength(struct IntuiText *);
static struct IntuiText itext= {
1,0,JAM1,0,0,&Topaz80,NULL,(struct IntuiText *)NULL
};
struct Gadget *CreateListView(x,y, c,l, tlist, id)
SHORT x,y;
SHORT c,l;
STRPTR *tlist;
USHORT id;
{
struct Gadget *glist, /* indexed (id,...,id+l-1) */
*slider; /* indexed (id+l,...,id+l+2) */
struct IntuiText *itlist;
struct Border *b;
SHORT n,w,h, tlines=0; /* #of text lines given */
STRPTR *t;
ULONG UserHandle= SetNewLookHandle(PRIVATE_HANDLE);
/* adjust parameters */
if(l<3) l=3;
if(c<1) c=1;
w= c * 8; /* Here we expect topaz.font to be */
h= l * (1+8+1); /* a non-proportional 8x8 font */
if(tlist)
{
/* compute tlist dimensions: cmax, lmax, w, h */
for(t= tlist; *t; t++, tlines++)
{
if((n= strlen(*t)) > c)
c= n;
itext.IText= *t;
if((n= IntuiTextLength(&itext)) > w)
w= n;
}
}
if((w+=4)>4 && h>0)
{
if(b= CreateBorder(-2,-1, 2+w+2,h+2, FALSE))
{
if(slider= CreateSlider(x+w+4,y-1,h+2,"B",id+l))
{
if(glist= (struct Gadget *)SmartAllocate(l*GADGETSIZE))
{
if(itlist= (struct IntuiText *)SmartAllocate(l*ITEXTSIZE))
{
for(n=0, t=tlist; n<l; n++)
{
/**/ itlist[n].FrontPen = 1;
itlist[n].BackPen = 0;
itlist[n].DrawMode = JAM1;
itlist[n].LeftEdge = 2;
itlist[n].TopEdge = 1;
itlist[n].ITextFont = &Topaz80;
itlist[n].IText = (n<tlines) ? *t++ : NULL;
itlist[n].NextText = (struct IntuiText *)NULL;
/**/ glist[n].NextGadget = (n<(l-1)) ? &glist[n+1] : slider;
glist[n].LeftEdge = x+2;
glist[n].TopEdge = y + n * (1+8+1);
glist[n].Width = w;
glist[n].Height = (1+8+1);
glist[n].Flags = GADGHCOMP;
glist[n].Activation = GADGIMMEDIATE|RELVERIFY;
glist[n].GadgetType = BOOLGADGET;
glist[n].GadgetRender = (APTR)NULL;
glist[n].SelectRender = (APTR)NULL;
glist[n].GadgetText = (struct IntuiText *)&itlist[n];
glist[n].MutualExclude = (LONG)0L;
glist[n].SpecialInfo = (APTR)NULL;
glist[n].GadgetID = id+n;
glist[n].UserData = (APTR)NULL;
}
glist[0].GadgetRender= b;
MakePrivateHandlePublic(UserHandle);
return glist;
}
}
}
}
}
if(UserHandle != PRIVATE_HANDLE)
{ SmartFreeAll(PRIVATE_HANDLE);
(void)SetNewLookHandle(UserHandle);
}
return (struct Gadget *)NULL;
}